<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
    const arrayRange = (array,index,distance = '+')=>{
        if(!Array.isArray(array||typeof index !== 'number' ||index<0)){
                    throw new TypeError('Argument(s) is illegal');
        }
        return array.slice(0,`${distance}${index}`)
    }
    const b = ['a', 'b', 'c'];
    const a = arrayRange(b, 2);
    console.log(a);
    console.log(b);

    //slice不会改变原来的数组
    //splice会改变
</script>